package com.neusoft.javafeatures9.his;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDate;
import java.util.Objects;

/**
 * his患者对象
 **/
@lombok.Getter
@Setter
@NoArgsConstructor
public  class PatientInfoEntity implements Comparable<PatientInfoEntity> {
    /**卡号*/
    private String cardNo;
    /**姓名*/
    private String name;
    /**身份证号*/
    private String idenno;
    /**出生日期*/
    private LocalDate birthday;
    /**是否删除*/
    private boolean isDeleted = false;
    private int sex;//1,2
    private long age;
    private String diagCode;//多条|分割

    public PatientInfoEntity(String name, String idenno, LocalDate birthday) {
        this.name = name;
        this.idenno = idenno;
        this.birthday = birthday;
    }

    public PatientInfoEntity(String name, int sex, long age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof PatientInfoEntity that)) return false;
        return Objects.equals(getCardNo(), that.getCardNo()) &&
                Objects.equals(getName(), that.getName()) &&
                Objects.equals(getIdenno(), that.getIdenno()) &&
                Objects.equals(getBirthday(), that.getBirthday());
    }

    @Override
    public int hashCode() {
        int result = Objects.hashCode(getCardNo());
        result = 31 * result + Objects.hashCode(getName());
        result = 31 * result + Objects.hashCode(getIdenno());
        result = 31 * result + Objects.hashCode(getBirthday());
        return result;
    }

    @Override
    public int compareTo(PatientInfoEntity o) {
        //按照年龄升序排序
        return Long.compare(this.age, o.age);
    }
}
